<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button>按钮了吧</button>
  <script>
    /* 
    this指向问题
      1.全局作用域下this指向window(定时器的this指向window)
      2.方法调用中谁调用this指向谁
      3.构造函数中this指向构造函数的实例对象
    */
    let o = {
      sayhai() {
        // 方法调用中谁调用this指向谁
        console.log(this);
        console.log(`好的把`);
      }
    };
    o.sayhai();

    let btn = document.querySelector("button");
    btn.addEventListener("click", () => {
      console.log(this);
    });
  </script>
</body>

</html>